this.name		= "Taiaha_Pickup";
this.author		= "Thargoid & Eric Walsh";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike.";
this.description	= "Pickup of a drone after combat, and check if it's reusable (T). New JS Scanning routine (EW).";
this.version		= "0.3";

this.shipWasScooped = function(scooper)
{
	if (scooper == player)
		{
		this.thePlayerShip = player;
		}
	if (scooper == player.ship)
		{
		this.thePlayerShip = player.ship;
		}
	if (scooper == player || scooper == player.ship)
	{
		let choice = (Math.ceil(Math.random()*3));
		if (choice == 3)
			{
			player.consoleMessage(this.ship.name+" circuits blown - only good for scrap machinery.", 6);
			this.thePlayerShip.awardCargo("Machinery", 1)
			}
		else
			{
			player.consoleMessage(this.ship.name+" recovered, recharged and ready for use.", 6);
			this.thePlayerShip.awardEquipment(this.ship.scriptInfo.DroneEquipment)
			}
	}
}

this.findMastersHostiles = function()
{
    function isHostileToMaster(entity) 
    { 
        return (entity.isShip && entity.target && entity.target == this.ship.master && entity.hasHostileTarget);
    }
    let targets = system.filteredEntities(this, isHostileToMaster, this.ship, 25600)
    if(targets.length > 0)
    {
        this.ship.target = targets[0];
        this.ship.reactToAIMessage("NEW_DRONE_TARGET");
        if(this.ship.master == player || this.ship.master == player.ship) player.commsMessage(this.ship.shipDescription+": Attacking "+targets[0].shipDisplayName)
    }
    else this.ship.reactToAIMessage("NOTHING_FOUND");
    
}
